/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : motor.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-11-27 init v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
********************************************************************************
*/

#include <stdio.h>
#include "motor.h"
#include "cmd_type.h"

#define MOTOR_LOGI(fmt, args...) printf("Motor: I: %d " fmt, __LINE__, ##args)
#define MOTOR_LOGD(fmt, args...) printf("Motor: D: %d " fmt, __LINE__, ##args)
#define MOTOR_LOGW(fmt, args...) printf("Motor: W: %d " fmt, __LINE__, ##args)
#define MOTOR_LOGE(fmt, args...) printf("Motor: E: %d " fmt, __LINE__, ##args)

CMotor* CMotor::GetInstance()
{
    static CMotor mObj;
    return &mObj;
}

int CMotor::ProcessMsg(long long cmdValue)
{
    MOTOR_LOGI("Get cmd: 0x%llx\n", cmdValue);

    switch (cmdValue)
    {
        case CMD_MOTOR_FORWARD:
            MotorForward();
        break;

        case CMD_MOTOR_BACKWARD:
            MotorBackward();
        break;

        default:
            MOTOR_LOGW("No process 0x%llx\n", cmdValue);
        break;
    }

    return 0;
}

void CMotor::MotorForward()
{
    MOTOR_LOGI("--- motor forward ---\n");
}

void CMotor::MotorBackward()
{
    MOTOR_LOGI("--- motor backward ---\n");
}